package com.example.highperformanceandroidtech.fragment;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.highperformanceandroidtech.R;

public class Example1_2Fragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_simple1_2,container,false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        ImageView imageView = view.findViewById(R.id.imageView);
        Button btnOval = view.findViewById(R.id.btnOval);
        btnOval.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.setBackground(getResources().getDrawable(R.drawable.background_oval_gradient));
            }
        });
        Button btnRing = view.findViewById(R.id.btnRing);
        btnRing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.setBackground(getResources().getDrawable(R.drawable.background_ring_gradient));
            }
        });
        Button btnRectangle = view.findViewById(R.id.btnRectangle);
        btnRectangle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.setBackgroundResource(R.drawable.background_rectangle_gradient);
            }
        });
        Button btnLine = view.findViewById(R.id.btnLine);
        btnLine.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.setMaxHeight(1);
                imageView.setBackgroundResource(R.drawable.background_line_gradient);
            }
        });
    }
}
